public class HToolsU2 implements HTools {
	
	public int h(int[] t, int me, int you) {
		if (compare(t, me, you, 2) == 1)
			return Integer.MIN_VALUE;
		
		int points = 0;
		
		int[] emptyHoles = new int[4];
		emptyHoles[1] = emptyHoles(t, 3);
		emptyHoles[2] = emptyHoles(t, 4);
		emptyHoles[3] = emptyHoles(t, 1);
		
		int iMax = 3;
		for (int i = iMax - 1; i > 0; i--)
			if (emptyHoles[i] > emptyHoles[iMax])
				iMax = i;
		points += 2 - iMax;
		
		int weight = 4;
		int[] cmp = new int[4];
		cmp[1] = compare(t, me, you, 3);
		cmp[2] = compare(t, me, you, 4);
		cmp[3] = compare(t, me, you, 1);
		
		for (int i = 3; i > 0; i--, weight *= 2)
			if (cmp[i] == 1)
				points += weight;
		
		return points;
	}
	
	public int compare(int[] t, int me, int you, int box) {
		return t[5 * me + box] - t[5 * you + box];
	}
	
	public int emptyHoles(int[] t, int box) {
		return Apagos.MAX[box] - t[t[11 + box]] - t[5 + t[11 + box]];
	}
}
